<?php

use services\models\cache\MemberInfo;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use \services\models\minisite\MActivityShowFeel;


/* @var $this yii\web\View */
/* @var $searchModel backend\models\MActivityShowFeelSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = MActivityShowFeel::$CHANNEL[Yii::$app->controller->channel] . '审核';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    td img {
        width: 50px;
        height: 50px;
        margin: 0 8px;
    }

    #show-table-show-fell table td:nth-child(4) .detail_content_show {
        width: 200px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>
<div class="box box-success">
    <div class="box-body"><?php echo $this->render('_search', ['model' => $searchModel]); ?></div>
</div>
<div class="mactivity-show-feel-index">
    <div class="box box-success">
        <div class="box-body">
            <?php Pjax::begin(['id' => 'show-table-show-fell']); ?>    <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'columns' => [
                    'id',
                    'uid',
                    [
                        'label' => '用户名',
                        'value' => function ($data) {
                            return MemberInfo::get($data->uid)->username;

                        }

                    ],
                    ['attribute' => 'c_content',
                        'value' => function ($data) {
                            return '<div class="detail_content_show" title="' . $data->c_content . '">' . $data->c_content . '</div>';
                        },
                        'format' => 'html',
                    ],
                    //'c_content:ntext',
                    ['attribute' => 'c_image',
                        'format' => 'raw',
                        'value' => function ($data) {
                            $str = '';
                            foreach (\services\models\UpFileData::showImages($data->c_image, 3) as $image)
                                $str .= Html::img($image, ['modalAble' => 1,]);
                            return $str;
                        },
                        'contentOptions' => ['class' => 'col-md-2']
                    ],
                    [
                        'label' => '标题',
                        'attribute' => 'c_name',
                    ],
                    'db_time',
                    [
                        'label' => '状态',
                        'value' => function ($data) {
                            return MActivityShowFeel::$STATUS[$data->c_status];
                        }
                    ],
                    [
                        'header' => '审核',
                        'class' => 'backend\components\ExaminationColumn',
                        'template' => '{examination}'
                    ]
                ],
            ]); ?>
            <?php Pjax::end(); ?></div>
    </div>
</div>
<?php
\yii\bootstrap\Modal::begin([
    'header' => '<h2 id="modalTitle">审核</h2>',
    'id' => 'modal',
    'size' => 'modal-lg',
]);
echo '<div id="modalContent"></div>';
\yii\bootstrap\Modal::end()
?>
<?php $this->beginBlock('js'); ?>
<script>
    $(function () {
        $('.glyphicon-check').parent().click(function () {
            $('#modalTitle').html('审核')
            var url = $(this).attr('href')
            //$(this).removeAttr('href')
            console.log(url);
            $('#modalContent').load(url + '&' + Math.random());
            $('#modal').modal('show')
            return false
        });
        $('img[modalable]').click(function () {
            $('#modalTitle').html('查看图片')
            $('#modalContent').html($(this).clone())
            $('#modalContent img').attr('style', 'width:600px;float:none')
            $('#modal').modal('show')
        });
    });
</script>

<?php $this->endBlock(); ?>
